# -*- coding: utf-8 -*-
import requests
import time
#import JSON
#proxys = "101.248.64.69:80"
#res =requests.get('http://icanhazip.com/', proxies={'http':"http://"+proxys,'https':"https://"+proxys} )#
##print(res.content.decode('utf-8').encode('gbk'))
#print(res.content.decode('utf-8'))
'''
PROXYS=[]
p_list = requests.get(url = "http://127.0.0.1:5010/get_all")
lines = p_list.text.split("\n")
for line in lines:
    if "\"" in line:
        proxy = line.strip()[1:-2]
        PROXYS.append(proxy)

#p_list = p_list.content.decode('utf-8')
print(PROXYS, len(PROXYS), type(PROXYS))

for proxy in PROXYS:
    print(proxy)
    r= None
    try:
        r = requests.get(url='http://icanhazip.com', proxies = {"http":"http://"+proxy})# 最基本的GET请求
        #r.encoding = 'utf-8'
        r = r.text#r.content.decode('utf-8')
    except:
        r = None
        
    print(r)
    
#    time.sleep(20)
'''
while(True):
    r = requests.get(url = "http://127.0.0.1:5010/get").text
    print(r)
    if len(r)<4:
        break
    time.sleep(3)
    
    proxy = r
    # print(proxy)
    r= None
    try:
        r = requests.get(url='http://www.baidu.com')#, proxies = {"http":"http://"+proxy})# 最基本的GET请求,icanhazip.com
        #r.encoding = 'utf-8'
        # r = r.text#r.content.decode('utf-8')
        driver.find_element_by_id('kw').send_keys(r'淮南58')
        driver.find_element_by_id('su').click()

        weblist = driver.find_elements_by_tag_name('h3')
        print (weblist)
        print(weblist[0].text)
    except:
        r = None
        
    print(r)
    
    